package cc.mango.android.chartview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.view.View;
import static cc.mango.android.chartutil.ChartCommons.*;

public class UpNoDataView extends View
{

	String		text	= "";

	/** The view bounds. */
	private int	width;
	private int	height;

	//bottom size
	int			bottomHeight;
	//left size
	int			leftWidth;
	//right size
	int			rightWidth;
	//top size
	int			topHeight;

	/*	public UpNoDataView(Context context) {
			super(context);
			// TODO Auto-generated constructor stub

			text = "暫時未有數據";

		}
		*/

	public UpNoDataView(Context context, String text)
	{
		super(context);
		// TODO Auto-generated constructor stub
		this.text = text;
	}

	@Override
	public void draw(Canvas canvas)
	{
		// TODO Auto-generated method stub
		super.draw(canvas);

		float x = leftWidth + (width - leftWidth - rightWidth) / 2;
		float y = topHeight + (height - topHeight - bottomHeight) / 2;

		Paint paint = new Paint();
		paint.setAntiAlias(true);
		paint.setColor(UP_CHART_BACKGROUND_COLOR);

		canvas.drawRect(leftWidth, topHeight, width - rightWidth, height
				- bottomHeight, paint);

		paint.setColor(UP_CHART_TOP_REGINE_COLOR);

		canvas.drawRect(leftWidth, topHeight, width - rightWidth, 0, paint);

		paint.setColor(Color.WHITE);
		paint.setTextSize(15);
		paint.setTextAlign(Align.CENTER);
		canvas.drawText(text, x, y, paint);

	}

	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh)
	{
		// TODO Auto-generated method stub
		super.onSizeChanged(w, h, oldw, oldh);

		width = w;
		height = h;
		initSize(w, h);
	}

	public void initSize(int width, int height)
	{

		leftWidth = width / 10;
		rightWidth = width / 25;
		topHeight = height / 8;
		bottomHeight = height / 8;

	}

}
